var app = getApp();

Page({
    data: {
        motto: "Hello World",
        userInfo: {},
        hasUserInfo: !1,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        swiperCurrent: 0,
        indicatorDots: !1,
        luntext: [ "最新", "未回复" ],
        activeIndex: 0,
        assess: [],
        page: 1,
        hide: !1
    },
    onLoad: function(e) {
        wx.hideShareMenu(), app.setNavigationBarColor(this);
        this.refresh();
    },
    refresh: function(e) {
        var t = this, s = t.data.page, a = t.data.assess, o = wx.getStorageSync("userInfo").id;
        app.util.request({
            url: "entry/wxapp/MyAssess",
            cachetime: "0",
            data: {
                user_id: o,
                page: s
            },
            success: function(e) {
                console.log("这是所有留言"), console.log(e), 0 < e.data.length && (a = a.concat(e.data), 
                t.setData({
                    assess: a,
                    page: s + 1
                }));
            }
        });
    },
    tabClick: function(e) {
        this.setData({
            sliderOffset: e.currentTarget.offsetLeft,
            activeIndex: e.currentTarget.id
        });
    },
    lyshanchu: function() {
        wx.showModal({
            title: "提示",
            content: "确定要删除？",
            success: function(e) {
                e.confirm ? console.log("用户点击确定") : e.cancel && console.log("用户点击取消");
            }
        });
    },
    hide: function(e) {
        var t = this, s = e.currentTarget.dataset.id;
        console.log(s), t.setData({
            assess_id: s
        });
        var a = t.data.hide;
        !1 === a ? t.setData({
            hide: !0
        }) : t.setData({
            hide: !1
        });
    },
    textarea: function(e) {
        console.log(e), this.setData({
            textarea: e.detail.value
        });
    },
    saves: function(e) {
        var t = this;
        console.log(t.data);
        var s = t.data.textarea, a = t.data.assess_id;
        "" == s || null == s ? wx.showModal({
            title: "",
            content: "请输入留言"
        }) : app.util.request({
            url: "entry/wxapp/SaveReply",
            data: {
                reply: s,
                assess_id: a
            },
            success: function(e) {
                console.log(e), wx.showToast({
                    title: "提交成功"
                }), setTimeout(function() {
                    t.setData({
                        hide: !1
                    });
                }, 1500), t.setData({
                    page: 1,
                    assess: []
                }), t.refresh();
            }
        });
    },
    sfshanchu: function(e) {
        var t = this, s = e.currentTarget.dataset.id;
        wx.showModal({
            title: "提示",
            content: "确定要删除？",
            success: function(e) {
                e.confirm ? (console.log("用户点击确定"), app.util.request({
                    url: "entry/wxapp/DelAssess",
                    data: {
                        assess_id: s
                    },
                    success: function(e) {
                        console.log(e), wx.showToast({
                            title: "提交成功"
                        }), t.setData({
                            page: 1,
                            assess: []
                        }), t.refresh();
                    }
                })) : e.cancel && console.log("用户点击取消");
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.refresh();
    }
});